import { CoolCommException } from '@cool-midway/core';
import { Rule, RuleType } from '@midwayjs/validate';
import { DemandTeamRequestStatus } from '../entity/request';

export class SubmitDemandRequestDTO {
  @Rule(RuleType.number().required().error(new CoolCommException('服务人员ID不能为空')))
  providerId: number;

  @Rule(
    RuleType.string()
      .required()
      .min(5)
      .max(1000)
      .error(new CoolCommException('请填写5-1000字的需求描述'))
  )
  description: string;

  @Rule(
    RuleType.string()
      .required()
      .max(50)
      .error(new CoolCommException('联系人姓名不能为空且最长50个字符'))
  )
  contactName: string;

  @Rule(
    RuleType.string()
      .required()
      .max(50)
      .error(new CoolCommException('联系方式不能为空且最长50个字符'))
  )
  contactInfo: string;
}

export class ProviderUpdateDemandStatusDTO {
  @Rule(RuleType.number().required().error(new CoolCommException('需求ID不能为空')))
  requestId: number;

  @Rule(
    RuleType.number()
      .valid(
        DemandTeamRequestStatus.PENDING,
        DemandTeamRequestStatus.FOLLOWING,
        DemandTeamRequestStatus.COMPLETED,
        DemandTeamRequestStatus.CLOSED
      )
      .error(new CoolCommException('非法的需求状态'))
  )
  status: DemandTeamRequestStatus;

  @Rule(
    RuleType.string()
      .allow('')
      .max(500)
      .error(new CoolCommException('备注不能超过500个字符'))
  )
  providerRemark?: string;
}

export class UserDemandDetailDTO {
  @Rule(RuleType.number().required().error(new CoolCommException('需求ID不能为空')))
  requestId: number;
}


